{% load i18n pagemagic_admin_tags adminmedia %}

{% if not level %}
    <tr style="background:#E1E1E1 url({% admin_media_prefix %}img/admin/nav-bg.gif) repeat-x scroll left top; border-bottom:1px solid #DDDDDD; color:#666666;">
        <td>
            {% trans "Name" %}
        </td>
        <td colspan="4">
            <a href="{{ model_admin_url }}add/" class="addlink" style="float:left; margin-right:2em">{% trans "Add page" %}</a>
        </td>
        <td colspan="2">
            {% trans "Path" %}
        </td>
        <td>
            {% trans "Handler" %}
        </td>
        <td>
            {% trans "Template" %}
        </td>
    </tr>
{% endif %}

{% if items %}
    {% for item in items %}
        <tr class="pagemagic-level-{{ level }} pagemagic-page-row {% global_cycle 'row1' 'row2' %}">
            <td style="white-space: nowrap">
                {{ item.name }}
            </td>
            <td style="width: 100%; white-space: nowrap; text-align: left;">
                {% for i in level_range %}&nbsp;&nbsp;&nbsp;&nbsp;{% endfor %}
                <span style="font-weight:normal; color:#aaa;">
                    |--
                </span>
                <a href="{{ model_admin_url }}{{ item.pk }}/" {% if not item.enabled %}style="color:#999;"{% endif %}>
                    {{ item.menu_item.title|default:"no title" }}
                    {% if not item.enabled %}
                        [{% trans "hidden" %}]&nbsp;
                    {% endif %}
                </a>
            </td>
            <td style="white-space: nowrap">
                <a href="{{ model_admin_url }}add/?parent={{ item.pk }}&path={{ item.path|default:"/" }}..." class="addlink"></a>
            </td>
            <td>
                {% if not forloop.first %}
                    <a href="{{ model_admin_url }}{{ item.pk }}/move-up/">
                        <img src="{% admin_media_prefix %}img/admin/arrow-up.gif" border="0" alt="{% trans 'up' %}"/>
                    </a>
                {% endif %}
            </td>
            <td>
                {% if not forloop.last %}
                    <a href="{{ model_admin_url }}{{ item.pk }}/move-down/">
                        <img src="{% admin_media_prefix %}img/admin/arrow-down.gif" border="0" alt="{% trans 'down' %}"/>
                    </a>
                {% endif %}
            </td>
            <td style="white-space:nowrap; width:20%">
                {{ item.path }}
            </td>
            <td>
                {% if item.path %}
                    <a href="{{ item.path }}">
                        <div style="background:#E1E1E1 url({% admin_media_prefix %}img/admin/inline-restore.png) repeat-x scroll right top; height:15px; width:18px">
                            &nbsp;
                        </div>
                    </a>
                {% endif %}
            </td>
            <td>
                {{ item.get_native_page_name }}
            </td>
            <td style="white-space: nowrap; width:20%">
                {{ item.content.template }}
            </td>
        </tr>
        {% show_admin_menu_branch item forloop %}
    {% endfor %}
{% endif %}